#!/usr/bin/python
# -*- coding: utf-8 -*-
# This Project Sscript Wrote By Yangyanbo
# If you have any question, Please contact to the email: berlinsaint@126.com
# Also QQ number is : 66375364
# Phone numer: 15855115899
# Date: Dev At '2016/7/13' : '10:22'
__author__ = 'Berlinsaint/yangyanbo'

from django import template
from main_page.views import  check_if_authenticated, check_if_admin,yesno
from main_page.libs.get_user_info import getuac
register = template.Library()

@check_if_authenticated
@check_if_admin
@register.filter
def get_uac(user_group):
    uacinfo = getuac(user_group)
    if not uacinfo:
        return u"暂无可用权限"
    else:
        st = u'数据上传: {} </br> 日志上传: {} </br> 上传次数: {}'.format(
            yesno(uacinfo.data_upload),
            yesno(uacinfo.log_upload),
            uacinfo.data_num
        )
        return st

@check_if_authenticated
@check_if_admin
@register.filter
def vip(user_group):
    #TODO 后续这里要放到数据表里
    if user_group == 0:
        return u"普通用户"
    elif user_group ==1:
        return u"会员用户"

    else:
        return  "Unknown"

@check_if_authenticated
@check_if_admin
@register.filter
def active(status):
    # TODO 后续这里要放到数据表里
    if status == 0:
        return u"未激活"
    elif status == 1:
        return u"已激活"

    else:
        return "Unknown"